package com.lj.ljminsu.houseDetails.controller;

import com.lj.ljminsu.houseDetails.service.HouseDetailService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@CrossOrigin
@RequestMapping("detail")
@RestController
public class DetailsController {
    @Resource
    private HouseDetailService houseDetailService;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    //房子状态
    @RequestMapping("houseStatus")
    public String houseStatus(Integer houseId){
        System.out.println("houseId:"+houseId);
        String json = houseDetailService.queryHouseDetails(houseId);
        return json;
    }
    //查房间详情
    @RequestMapping("{houseId}")
    public String houseInfo(@PathVariable Integer houseId){
        String info = houseDetailService.queryHouseInfo(houseId);
        return info;
    }
    //普通订购时房间数量
    @RequestMapping("houseNum")
    public Integer houseNum(String msg){
        System.out.println(msg);//msg中是预定时间+房源id
            String[] split = msg.split("#");
            String start = split[0];//预定日期
            String houseId = split[1];//房屋id
            Integer houseNum = houseDetailService.queryHouseNum(Integer.parseInt(houseId), start);//当天能被预定的房间数
        return 1;
    }
    @RequestMapping("calendar")
    public String calendar(){

        return null;
    }
}
